/**
 * 行查管家_领航乐行 共用方法的封装
 */

let xcgj = {
	/**
	 * @description 订单标题 
	 * <br/>this.utilXcgj.titleFilter(order)
	 * @param {string} order 订单信息 
	 */
	titleFilter: function(order) {
		
		let receive = order.receive_address_type ? order.receive_address_type : '0'
		let send = order.send_address_type ? order.send_address_type : '0'
		let short_code = order.project_code

		// console.log()
		const short = {
			'DD': '行李',
			'PT': '宠物',
			'BA': '球包',
			'FD': '飞递'
		}
		const key2 = short[short_code]
		const options = {
			'0-0': `${key2}门到门`,
			'0-1': `${key2}门到港`,
			'1-0': `${key2}港到门`,
			'1-1': `${key2}港到港`,
		};
		const key = `${send}-${receive}`;
		return options[key] || `${key2}门到门`;
	},

	/**
	 * @description 物品信息
	 * <br/>this.utilXcgj.titleFilter(order)
	 * @param {string} order 订单信息 
	 */
	information(order) {
		let short_code = order.nav_luggage_orders[0].short_code
		const short = {
			'DD': '行李',
			'PT': '宠物',
			'BA': '球包',
			'FD': '飞递'
		}
		const key2 = short[short_code]
		let ordernum = order.nav_luggage_orders.length
		return `${key2} ${ordernum}件`
	},
	
	/**
	 * @description 物品类型
	 * <br/>this.utilXcgj.titleFilter(order)
	 * @param {string} order 订单信息 
	 */
	inforType(order) {
		let short_code = order.nav_luggage_orders[0].short_code
		const short = {
			'DD': '行李',
			'PT': '宠物',
			'BA': '球包',
			'FD': '飞递'
		}
		const key2 = short[short_code]
	
		return `${key2}`
	},
	/**
	 * @description 拨打电话
	 * <br/>this.utilXcgj.titleFilter(order)
	 * @param {string} order 订单信息 
	 */

	makePhoneCall(value) {
		uni.makePhoneCall({
			phoneNumber: value, // 电话号码
			success() {
				console.log('拨打电话成功')
			},
			fail(err) {
				console.error('拨打电话失败', err)
			}
		})
	},
	
	copy(value) {
		uni.setClipboardData({
			data: value,
			success: () => {
				uni.showToast({
					title: '复制成功',
					icon: 'success',
					duration: 2000
				});
			},
		});
	},

}

export default xcgj;